<?php
ob_start();
session_start();
include "checksession.php";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Adinop Co., Ltd. was founded as an ingredients importer and local manufacturers’ distributor in 1986. We also function as an exporter of finished products</title>
		<link href="../images/it_service_logo.png" rel="shortcut icon" type="image/x-icon" />
        <link rel="stylesheet" href="../css/style.css"/>
        <script type="text/javascript" src="../js/jquery/jquery.js"></script>
        <script type="text/javascript" src="../js/jquery/jquery.validationEngine.js"></script>
        <link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css" />
        <!--<script language="javascript" src="../js/jquery/jquery-1.7.1.min"></script>-->
        <script type="text/javascript" src="../fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
        <script type="text/javascript" src="../fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
        <link rel="stylesheet" type="text/css" href="../fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
        <link rel="stylesheet" href="../fancybox/style.css" />

        <script type="text/javascript">
            $(function() {
                var objSet = "#txtKeyword";
                var objSetText = "ค้นหาด้วย รหัส,ชื่อ,แผนก,หมายเลขเครื่อง";
                if ($(objSet).val() == "") {
                    $(objSet).val(objSetText);
                }
                $(objSet).focus(function() {
                    if ($(objSet).val() == objSetText) {
                        $(objSet).val("");
                    }
                }).blur(function() {
                    if ($(objSet).val() == "") {
                        $(objSet).val(objSetText);
                    }
                });
            });
        </script>
        <script type="text/javascript">

            $(document).ready(function() {

                $("#addCom").fancybox({
                    'width': '100%',
                    'height': '100%',
                    'autoScale': true,
                    'scrolling': 'auto',
                    'transitionIn': 'elastic',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'overlayColor': '#000',
                    'hideOnOverlayClick': false,
                    onCleanup: function() {
                        return window.location.reload();
                    }
                });

                $("#addnotebook").fancybox({
                    'width': '100%',
                    'height': '100%',
                    'autoScale': true,
                    'scrolling': 'auto',
                    'transitionIn': 'elastic',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'overlayColor': '#000',
                    'hideOnOverlayClick': false,
                    onCleanup: function() {
                        return window.location.reload();
                    }
                });

                $('a[id^="edit"]').fancybox({
                    'width': '100%',
                    'height': '100%',
                    'autoScale': true,
                    'scrolling': 'auto',
                    'transitionIn': 'elastic',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'overlayColor': '#000',
                    'hideOnOverlayClick': false,
                    onClosed: function() {
                        parent.location.reload(true);
                    }
                });

                $('a[id^="delete"]').fancybox({
                    'width': '20%',
                    'height': '20%',
                    onStart: function() {
                        return window.confirm('คุณต้องการลบรายการนี้ไหม?');
                    },
                    onClosed: function() {
                        parent.location.reload(true);
                    }
                });
            });
        </script>
    </head>
    <body> 
        <body class="body">
            <table align="center" width="90%">
                <tr>
                    <td colspan="2" class="header" >
                        <img src="../images/logo.png"> <img src="../images/it_service_text.png" width ="150">
                            <hr/>
                    </td>
                </tr >

                <tr  valign="top">
                    <td class="left">
                        <?php include_once "left.php"; ?>
                    </td>
                    <td>
                        <div align="right">
                            <form id="searchperson" name="txtKeyword" method="get" action="searchListCom.php">
                                <input name="txtKeyword" size="35" type="text" id="txtKeyword" class="validate[required]"/>
<!--                                <input type="hidden" name="hidOK">-->
                                <input type="image" name="search" id="search" value="submit" src="../images/search.png">
                            </form>
                        </div>
                        <?
                        include_once '../connect.php';
                        $strSQL = "SELECT  *  FROM comname LEFT  JOIN depart ON comname.de_id = depart.id
                                                         LEFT  JOIN computer ON comname.cn_id = computer.cn_id                                                      
                                                         LEFT  JOIN employee ON comname.emp_id = employee.emp_id
                                                         LEFT  JOIN userlog  ON comname.id_member = userlog.id_member
                                                         LEFT  JOIN product_detail ON comname.cn_number =  product_detail.pd_id
                                            ";
                        $objQuery = mysql_query($strSQL) or die("Error Query [" . $strSQL . "]");
                        $Num_Rows = mysql_num_rows($objQuery);
                        $n = 1;
                        $Per_Page = 7;   // Per Page

                        $Page = $_GET["Page"];
                        if (!$_GET["Page"]) {
                            $Page = 1;
                        }

                        $Prev_Page = $Page - 1;
                        $Next_Page = $Page + 1;

                        $Page_Start = (($Per_Page * $Page) - $Per_Page);
                        if ($Num_Rows <= $Per_Page) {
                            $Num_Pages = 1;
                        } else if (($Num_Rows % $Per_Page) == 0) {
                            $Num_Pages = ($Num_Rows / $Per_Page);
                        } else {
                            $Num_Pages = ($Num_Rows / $Per_Page) + 1;
                            $Num_Pages = (int) $Num_Pages;
                        }

                        $strSQL .=" order  by cn_createdate DESC LIMIT $Page_Start , $Per_Page";
                        $objQuery = mysql_query($strSQL);
                        ?>

                        <div align="right">
                            <a id="addCom" href="addListCom.php">
                                <img src="../images/computer_add.png" width="40px" >
                            </a>
                            <a id="addnotebook" href="addNotebookListCom.php">
                                <img src="../images/addnotebook.png" width="40px" >
                            </a>

                            <a href="report_computername.php" target="bank">
                                <img src="../images/print_empty.png" width="45px">
                            </a>
                            <a href="report_recordmaintenance.php" target="bank">
                                <img src="../images/reportmaintenance.png" width="45px">
                            </a>
                        </div>
                        <div class="nameTitle">รายชื่อเครื่องคอมพิวเตอร์</div>
                        <table width="100%"  border="0" align="center"  cellpadding="1" cellspacing="0" class="simply">
                            <thead>
                                <tr>
                                    <th width="5%">ลำดับ</th> 
                                    <th width="10%">รหัสเครื่อง</th>
                                    <th width="10%">ชื่อเครื่อง</th>
                                    <th width="10%">รหัสพนักงาน</th>
                                    <th width="10%">ชื่อผู้ใช้</th>
                                    <th width="10%">แผนกฝ่าย</th>
                                    <th width="10%">IP Address</th>
                                    <th width="10%">ผู้จัดทำ</th>
                                    <th width="5%">แก้ไข</th>
                                    <th width="5%">ลบ</th>
                                    <th width="5%">Report</th>
<!--                                    <th width="5%">เปลี่ยนอุปกรณ์</th>-->
                                </tr>
                            </thead>
                            <?
                            $n = 1;
                            if ($Page > 1) {
                                $n = ($Per_Page * ($Page - 1)) + 1;
                            }
                            while ($objResult = mysql_fetch_array($objQuery)) {
                                ?>
                                <tbody>
                                    <tr>
                                        <td width="5%">  <?php echo $n++; ?></td>
                                        <td width="10%"><?= $objResult["pd_name"]; ?></td>
                                        <td width="10%"><?= $objResult["cn_comeName"]; ?></td>
                                        <td width="10%"><?= $objResult["6"]; ?></td>
                                        <td width="10%"><?= $objResult["emp_nameEng"]; ?></td>
                                        <td width="10%"><?= $objResult["departname"]; ?></td>
                                        <td width="10%"><?= $objResult["cn_ip"]; ?></td>
                                        <td width="10%"><?= $objResult["f_name"]; ?></td>
                                        <td width="5%">
                                            <a id="edit<?= $n; ?>" href="updateListCom.php?cn_id=<?= $objResult["0"]; ?>">
                                                <img src="../images/write.png" width="35px" > </td>
                                                    <td width="5%">
                                                        <a href="home.php?url=listCom_delete&cn_id=<?= $objResult["0"]; ?>&c_id=<?= $objResult["c_id"]; ?>&emp_id=<?= $objResult["emp_id"]; ?>&cn_number=<?= $objResult["cn_number"]; ?>&c_keyboard=<?= $objResult["c_keyboard"]; ?>&c_mouse=<?= $objResult["c_mouse"]; ?>&c_monitor=<?= $objResult["c_monitor"]; ?> "onclick="return confirm('what do you want Delete')">
                                                            <img src="../images/deletered.png" width="35px" >
                                                        </a>
                                                    </td>
                                                    <td width="5%"> 
                                                        <a href="report_recordcomputer.php?cn_id=<?= $objResult["0"]; ?>&c_refNumber=<?= $objResult["c_refNumber"]; ?>"target="bank">
                                                            <img src="../images/pdf.png" width="35px" >
                                                        </a>

                                                        </tr>
                                                        <?
                                                    }
                                                    ?>
                                                    </tbody>
                                                    </table>
                                                    <table width="100%"  border="0" align="center" cellpadding="1" cellspacing="0" class="simply">
                                                        <tr>
                                                            <td>
                                                                <br>
                                                                    Total <?= $Num_Rows; ?> Record : <?= $Num_Pages; ?> Page :
                                                                    <?
                                                                    if ($Prev_Page) {
                                                                        echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
                                                                    }

                                                                    for ($i = 1; $i <= $Num_Pages; $i++) {
                                                                        if ($i != $Page) {
                                                                            echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
                                                                        } else {
                                                                            echo "<b> $i </b>";
                                                                        }
                                                                    }
                                                                    if ($Page != $Num_Pages) {
                                                                        echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
                                                                    }
                                                                    ?>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                                </tr>  
                                                <tr>
                                                    <td colspan="2">
                                                        <div><a href="../checklogout.php" onclick="return confirm('what do you want Exit')"> <img src="../images/logout.png" width="150px"></img></a></div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="footer" colspan="2">
                                                        Powered by Department Technology information Adinop
                                                    </td>
                                                </tr>
                                                </table>
                                                </body>
                                                </html>